package com.gss.system.controller;

import com.gss.common.core.controller.BaseController;
import com.gss.entity.R;
import com.gss.entity.enums.ConstantEnum;
import com.gss.entity.sys.dto.SysDept;
import com.gss.entity.sys.vo.SysDeptRoleVo;
import com.gss.system.service.ISysDeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author DYang
 * @date 2023/6/17
 */
@Api(tags = "部门管理")
@CrossOrigin
@RestController
@RequestMapping("/dept")
public class SysDeptController extends BaseController<SysDept> {

    @Autowired
    private ISysDeptService sysDeptService;

    @ApiOperation(value = "部门关联角色",tags = "部门管理")
    @PostMapping("/oauthRole")
    public R<String> oauthRole(@RequestBody SysDeptRoleVo entity){
        if (entity == null) {
            return R.error(ConstantEnum.PARAM_ERROR);
        }
        return sysDeptService.oauthRole(entity);
    }

    @ApiOperation(value = "部门撤销角色",tags = "部门管理")
    @DeleteMapping("/deleteRole")
    public R<String> deleteRole(@RequestBody List<Integer> idList){
        if (idList == null) {
            return R.error(ConstantEnum.PARAM_ERROR);
        }
        return sysDeptService.deleteRole(idList);
    }

}
